package mobao;

import mobao.filter.ErrorFilter;
import mobao.filter.moboDemoFilter;
import org.springframework.boot.autoconfigure.web.DefaultErrorAttributes;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.cloud.client.SpringCloudApplication;
import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
import org.springframework.context.annotation.Bean;


/**
 * Created by yanghongquan on 2018/8/13 16:25
 */
@EnableZuulProxy
@SpringCloudApplication
public class ApiGatewayApplication {
    public static void main(String[] args) {
        new SpringApplicationBuilder(ApiGatewayApplication.class).web(true).run(args);
    }

    /**
     * 建的过滤器要在此处实例化Bean
     */
    @Bean
    public moboDemoFilter testFilter(){
        return new moboDemoFilter();
    }
    @Bean
    public ErrorFilter errorFilter(){
        return new ErrorFilter();
    }

    /**
     * 自定义异常生效
     */
    @Bean
    public DefaultErrorAttributes errorAttributes(){
        return new DefaultErrorAttributes();
    }

}
